package servlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import domain.BlackList;
import domain.UserClickCount;
import service.BlackListService;
import service.UserClickCountService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/Servlet07")
public class Servlet07 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.v->c:从页面读取参数，利用req对象
        //2.c->m->c：处理数据，调用DAO访问数据库，同时得到返回值0
        BlackListService contactsService = new BlackListService();
        String json = contactsService.ToJson();

        System.out.println(json);

        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(json);
    }
}
